package app.beit.finportal.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import app.beit.finportal.bean.RelativeWebProgramsBean;
import app.beit.finportal.service.RelativeWebProgramsService;
import app.beit.finportal.utils.constr.RelativeWebProgramsConstr;
import app.beit.finportal.utils.constr.SessionConstr;

@Controller
@RequestMapping("/websites")
public class WebsitesController extends BaseController {
	


	private final Logger log = Logger.getLogger(this.getClass());

	@Autowired
	private RelativeWebProgramsService relativeWebProgramsService;

	@RequestMapping
	public String index(final HttpServletRequest request) throws Exception {
		super.startProcess(request);
		//super.removeAllSession(request);
		request.setAttribute(SessionConstr.ACTIVE_PAGE, "websites");

		try {
			final List<RelativeWebProgramsBean> beans = this.relativeWebProgramsService.getAllByTypes(RelativeWebProgramsConstr.TYPE_WEB);
			if (beans != null && beans.size() > 0) {
				request.setAttribute(SessionConstr.DOCUMENTS_ALL_DATAS,beans);
			}
		} catch (Exception ex) {
			this.log.error(ex.getMessage());
			ex.printStackTrace();
		}

		return "websites";
	}

}
